package com.zfy.tingshu.album.api;

import com.alibaba.fastjson.JSONObject;
import com.zfy.tingshu.album.service.BaseCategoryService;
import com.zfy.tingshu.common.result.Result;
import com.zfy.tingshu.model.album.BaseCategory1;
import com.zfy.tingshu.model.album.BaseCategory3;
import com.zfy.tingshu.model.album.BaseCategoryView;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


@Tag(name = "分类管理")
@RestController
@RequestMapping(value="/api/album/category")
@SuppressWarnings({"all"})
public class BaseCategoryApiController {
	
	@Autowired
	private BaseCategoryService baseCategoryService;


	@Operation(summary = "获取全部一级分类")
	@GetMapping("/findAllCategory1")
	public Result<List<BaseCategory1>> findAllCategory1(){
		//调用服务层方法
		return Result.ok(baseCategoryService.list());
	}


	/**
	 * 获取分类数据
	 */
	@Operation(summary = "获取分类数据")
	@GetMapping("/getBaseCategoryList")
	public Result getBaseCategoryList(){
		//调用服务层方法
		List<JSONObject> list=baseCategoryService.getBaseCategoryList();
		//返回数据
		return Result.ok(list);
	}
	/**
	 * 专辑简介
	 */
	@Operation(summary = "根据id获取简介")
	@GetMapping("/findAttribute/{category1_id}")
	public Result findAttribute(@PathVariable Integer category1_id){
		return Result.ok(baseCategoryService.findAttribute(category1_id));
	}

	@Operation(summary = "根据3级id分类")
	@GetMapping("/getBaseCategoryView/{category3_Id}")
	public Result<BaseCategoryView> getBaseCategoryView(@PathVariable("category3_Id") Long category3_Id){
		return Result.ok(baseCategoryService.getBaseCategoryView(category3_Id));
	}

	@Operation(summary = "根据1级分类获取")
	@GetMapping("getBaseCategoryList/{category1Id}")
	public Result<JSONObject> getBaseCategoryList(@PathVariable("category1Id")Long category1Id){
		return Result.ok(baseCategoryService.getBaseCategory1List(category1Id));
	}
	@Operation(summary = "获取一级分类下置顶到频道页的三级分类列表")
	@GetMapping("findTopBaseCategory3/{category1Id}")
	public Result<List<BaseCategory3>> findTopBaseCategory3(@PathVariable Long category1Id){
		//获取3级分类列表
		return Result.ok(baseCategoryService.findTopBaseCategory3(category1Id));
	}

}

